package cn.gem.rainbow.cfg;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;

@Data
// 注册为组件
@Component
// 启用配置自动注入功能
@EnableConfigurationProperties
//指定类对应的配置项前缀
@ConfigurationProperties(prefix = "system-param")
//启动校验-只需要在我们创建的配置Properties类增加Validation相关配置即可
@Validated
@ApiModel(description = "系统参数")
public class SystemParam {
    @ApiModelProperty(value = "appName")
    @NotEmpty(message = "yml配置文件配置必须要配置[system-param.app-name]属性")
    private String appName;
    @ApiModelProperty(value = "appVersion")
    @NotEmpty(message = "yml配置文件配置必须要配置[system-param.app-version]属性")
    private String appVersion;
    @ApiModelProperty(value = "appChineseName")
    @NotEmpty(message = "yml配置文件配置必须要配置[system-param.app-chinese-name]属性")
    private String appChineseName;
    @ApiModelProperty(value = "appDeveloper")
    @NotEmpty(message = "yml配置文件配置必须要配置[system-param.app-developer]属性")
    private String appDeveloper;
    @ApiModelProperty(value = "appSessionTimeoutSeconds")
    @NotNull(message = "yml配置文件配置必须要配置[system-param.appSessionTimeoutSeconds]属性")
    private Long appSessionTimeoutSeconds;

    @NotEmpty(message = "yml配置文件配置必须要配置[system-param.whitelist]属性")
    private List<String> whitelist;

    private String limitUrl;
    private String limitMaxRequest;

    private Map<String,String> maps;

    private Map<String,List<String>> varmaplist;

}
